package com.ledim.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.ledim.adapter.base.LedimBaseListAdapter;
import com.letv.android.young.client.R;
import java.util.ArrayList;

public class SearchRecordAdapter extends LedimBaseListAdapter<String> {
    
    public SearchRecordAdapter(Context context, ArrayList<String> list) {
        super(context);
        setDatas(list);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.item_search_records, null);
            holder.mName = (TextView) convertView.findViewById(R.id.search_record_item);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        String name = getItem(position);
        if (name.length() > 9) {
            holder.mName.setText(
                    name.substring(0, 5) + "…" + name.substring(name.length() - 4, name.length()));
        } else {
            holder.mName.setText(name);
        }

        return convertView;
    }

    public static class ViewHolder {

        private TextView mName;
    }
}
